function [counts] = checksimilarity( w,k )
    [zero one two three four five six seven eight nine ...
    zero_t one_t two_t three_t four_t five_t six_t seven_t eight_t nine_t test training] = parsedata();

    % Check the accuracy of our labels
    % 1. take a single example from the test set
    % 2. run similarity on it vs every single example from the training set
    % 3. have it output the digit that has the highest similarity    
    counts = zeros(1,11);
    distances = zeros(size(training,1),2);
    
    for i=1:size(zero_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),zero_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        str = sprintf('%d estimated %d',i,estimate);
        str
        if(estimate == 0)
            counts(1) = counts(1) + 1;
        end
    end

    counts(1)
    counts(11) = counts(1) + counts(11);
    counts(1) = (1 - counts(1)/size(zero_t,1));
    
    counts(1)
    
    for i=1:size(one_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),one_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 1)
            counts(2) = counts(2) + 1;
        end
    end

    counts(11) = counts(2) + counts(11);
    counts(2) = (1 - counts(2)/size(one_t,1));
    
    counts(2)
    
    for i=1:size(two_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),two_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 2)
            counts(3) = counts(3) + 1;
        end
    end

    counts(11) = counts(3) + counts(11);
    counts(3) = (1 - counts(3)/size(two_t,1));
    
    counts(3)
    
    
    for i=1:size(three_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),three_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 3)
            counts(4) = counts(4) + 1;
        end
    end

    counts(11) = counts(4) + counts(11);
    counts(4) = (1 - counts(4)/size(three_t,1));
    
    counts(4)
    
    for i=1:size(four_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),four_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 4)
            counts(5) = counts(5) + 1;
        end
    end

    counts(11) = counts(5) + counts(11);
    counts(5) = (1 - counts(5)/size(four_t,1));
    
    counts(5)
    
    for i=1:size(five_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),five_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 5)
            counts(6) = counts(6) + 1;
        end
    end

    counts(11) = counts(6) + counts(11);
    counts(6) = (1 - counts(6)/size(five_t,1));
    
    counts(6)
    
    for i=1:size(six_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),six_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 6)
            counts(7) = counts(7) + 1;
        end
    end

    counts(11) = counts(7) + counts(11);
    counts(7) = (1 - counts(7)/size(six_t,1));
    
    counts(7)
    
    for i=1:size(seven_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),seven_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 7)
            counts(8) = counts(8) + 1;
        end
    end

    counts(11) = counts(8) + counts(11);
    counts(8) = (1 - counts(8)/size(seven_t,1));
    
    counts(8)
    
    for i=1:size(eight_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),eight_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 8)
            counts(9) = counts(9) + 1;
        end
    end

    counts(11) = counts(9) + counts(11);
    counts(9) = (1 - counts(9)/size(eight_t,1));
    
    counts(9)
    
    for i=1:size(nine_t,1)
        distances(:,1) = training(:,1);

        distances(:,2) = -1*s(w',training(:,2:end),nine_t(i,:));
        distances = sortrows(distances,2);
        estimate = getlabel(distances(1:k,:));
        if(estimate == 9)
            counts(10) = counts(10) + 1;
        end
    end

    counts(11) = counts(10) + counts(11);
    counts(10) = (1 - counts(10)/size(nine_t,1));
    
    counts(10)
    
    counts(11) = (1 - counts(11)/size(test,1));
end
